package com.mrjoew.weekend.entities;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @author Christopher Jones
 * @ClassName Base
 * @explain 公共继承类
 * @date 2020/6/17 0017 14:57
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
@Where(clause = "deleted = 0")
public class BasePO implements Serializable {

    private static final long serialVersionUID = 2608319169657294086L;

    /**
     * ID
     */
    @Id
    @Column(name = "id", length = 11)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
     * 公用字段
     */
    @Column(name = "title", length = 64)
    private String title;

    @JsonIgnore
    private Date createTime = new Date();

    @JsonIgnore
    @Column(name = "create_user", length = 11)
    private Integer createUser;

    /**
     * 最后更新
     */
    @JsonIgnore
    private Date modifyTime;

    @JsonIgnore
    @Column(name = "modify_user", length = 11)
    private Integer modifyUser;

    @JsonIgnore
    @Column(name = "deleted", length = 1)
    private Integer deleted = 0;

    public boolean deleted() {
        return deleted != null && deleted != 1;
    }
}
